package com.zxy.dao;

import cn.echo.annotation.PageX;
import com.zxy.model.RegisterInfo;
import com.zxy.model.User;
import com.zxy.model.UserQuery;
import com.zxy.model.UserRoles;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserDao {
    User select(String tel);
    @PageX
    List<User> selectList(UserQuery query);

    int register(RegisterInfo registerInfo);
    User login(String tel,String password);

    int insert(RegisterInfo registerInfo);
//    @Select("select u.id as userId,  r.name as roleName  from `206_user` u \n" +
//            "left join `206_user_roles` ur on u.id= ur.user_id \n" +
//            "left join `206_roles` r  on ur.role_id  = r.id \n" +
//            "where u.id= #{userId}")
    List<UserRoles> selectRole(int userId);

//    @Select(" select p.name  from `206_user` u \n" +
//            "inner join `206_user_roles` ur on u.id= ur.user_id \n" +
//            "inner join `206_role_permissions` rp on rp.role_id= ur.role_id \n" +
//            "inner join `206_permissions` p  on p.id  = rp.permissions_id\n" +
//            "where u.id= #{userId} ")
    List<String> getPermission(int userId);
}
